package kr.hkit.androidcomplete02.ch16;

import kr.hkit.androidcomplete02.R;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

public class AlertDialogEx extends Activity {
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.ch16_alertdialog);
	}
	
	public void mOnClick(View v){
		//final int flag;
		new AlertDialog.Builder(this)
		.setTitle("알립니다.")
		.setMessage("대화상자를 열었습니다")
		// back 버튼이 동작하지 않도록 함.
		.setCancelable(false)
		.setIcon(R.drawable.androboy)
		// 왼쪽 (which : 순서)
		.setPositiveButton("확인", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				Toast.makeText(getApplication(), "확인버튼" + which, Toast.LENGTH_SHORT).show();
				//flag = which;
			}
		})
		// 오른쪽
		.setNegativeButton("닫기", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				Toast.makeText(getApplication(), "취소버튼" + which, Toast.LENGTH_SHORT).show();
				//flag = which;
			}
		})
		.setNeutralButton("중간", new DialogInterface.OnClickListener() {
			public void onClick(DialogInterface dialog, int which) {
				Toast.makeText(getApplication(), "중간버튼" + which, Toast.LENGTH_SHORT).show();
				//flag = which;
			}
		}).show();		
	}
}
